<?php $this->load->view('layout/header');?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h3 class="page-title">提现管理<small> 提现记录</small></h3>
            <?php echo breadcrumb(array('提现管理','提现记录')); ?>
        </div>
    </div>
    <?php echo execute_alert_message() ?>
    <div class="row-fluid">
        <div class="span12">
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-search"></i>搜索</div>
                    <div class="tools">
                        <a class="collapse" href="javascript:;"></a>
                        <a class="remove" href="javascript:;"></a>
                    </div>
                </div>
                <div class="portlet-body form">
                    <form class="form-horizontal form-search" action="<?php echo base_url('withdraw/index') ?>" method="get">
                        <div class="row-fluid">
                            <div class="span4">
                                <div class="control-group">
                                    <label class="control-label">提现编号</label>
                                    <div class="controls">
                                        <input type="text" name="withdraw_id" value="<?php echo $this->input->get('withdraw_id');?>" placeholder="提现编号" class="m-wrap medium">
                                    </div>
                                </div>
                            </div>
                            <div class="span4">
                                <div class="control-group">
                                    <label class="control-label">用户登录名</label>
                                    <div class="controls">
                                        <input type="text" name="user_name" value="<?php echo $this->input->get('user_name');?>" placeholder="用户名或用户编号" class="m-wrap medium">
                                    </div>
                                </div>
                            </div>
                            <div class="span4">
                                <div class="control-group">
                                    <label class="control-label">支付状态</label>
                                    <div class="controls">
                                        <select class="medium m-wrap" name="status">
                                            <option value="0">请选择</option>
                                            <?php foreach ($status as $key => $value) : ?>
                                            <option value="<?php echo $key; ?>" <?php if($this->input->get('status') == $key){echo 'selected="selected"';} ?> ><?php echo $value; ?></option>
                                            <?php endforeach; ?>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row-fluid">
                            <div class="span4">
                                <div class="control-group">
                                    <label class="control-label">持卡人</label>
                                    <div class="controls">
                                        <input type="text" name="cardholder" value="<?php echo $this->input->get('cardholder');?>" placeholder="持卡人" class="m-wrap medium">
                                    </div>
                                </div>
                            </div>
                            <div class="span4">
                                <div class="control-group">
                                    <label class="control-label">手机号码</label>
                                    <div class="controls">
                                        <input type="text" name="mobile_phone" value="<?php echo $this->input->get('mobile_phone');?>" placeholder="预留手机号码" class="m-wrap medium">
                                    </div>
                                </div>
                            </div>
                            <div class="span4">
                                <div class="control-group">
                                    <label class="control-label">审核状态</label>
                                    <div class="controls">
                                        <select class="medium m-wrap" name="auditStatus">
                                            <option value="0">全部</option>
                                            <option value="1" <?php if($this->input->get('auditStatus') == 1){echo 'selected="selected"';} ?> >待审核</option>
                                            <option value="2" <?php if($this->input->get('auditStatus') == 2){echo 'selected="selected"';} ?> >审核成功</option>
                                            <option value="2" <?php if($this->input->get('auditStatus') == 3){echo 'selected="selected"';} ?> >审核失败</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row-fluid">
                            <div class="span4">
                                <div class="control-group">
                                    <label class="control-label">提现金额</label>
                                    <div class="controls">
                                        <input type="text" name="amount" value="<?php echo $this->input->get('amount');?>" placeholder="金额" class="m-wrap medium">
                                    </div>
                                </div>
                            </div>
                            <div class="span4">
                                <label class="control-label">提现时间</label>
                                <div class="controls form-search-time">
                                    <div class="input-append date date-picker">
                                        <input type="text" name="start_date" size="16" value="<?php echo $this->input->get('start_date');?>" class="m-wrap m-ctrl-medium date-picker date">
                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                    </div>
                                    <div class="input-append date date-picker">
                                        <input type="text" name="end_date" size="16" value="<?php echo $this->input->get('end_date');?>" class="m-wrap m-ctrl-medium date-picker date">
                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                    </div>
                                </div>
                            </div>

                            
                        </div>
                        <div class="form-actions">
                            <button class="btn green" type="submit">搜索</button>
                            <button class="btn reset_button_search" type="button">重置条件</button>
                        </div>
                    </form>
                </div>
            </div>
            
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>列表</div>
                    <div class="tools">
                        <a class="collapse" href="javascript:;"></a>
                        <a class="remove" href="javascript:;"></a>
                    </div>
                </div>
                <div class="portlet-body flip-scroll">
                    <div class="dataTables_wrapper form-inline">
                        <?php if ($all_rows > 0) :?>
                        <table class="table table-striped table-bordered table-hover" id="sample_1">
                            <thead class="flip-content">
                                <tr>
                                    <th width="30"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"></th>
                                    <th width="40">提现编号</th>
                                    <th>用户名</th>
                                    <th>提现金额</th>
                                    <th width="160">银行卡信息</th>
                                    <th>证件号码</th>
                                    <th>提现设备</th>
                                    <th>提现时间</th>
                                    <th>审核</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($page_list->result() as $item) : ?>
                                <tr>
                                    <td><input type="checkbox" class="checkboxes" value="1" ></td>
                                    <td><?php echo $item->withdraw_id;?></td>
                                    <td><?php echo $item->user_name, '/', $item->uid;?></td>
                                    <td><?php echo number_format($item->amount, 2, '.', ',');?></td>
                                    <td><?php echo  $item->bank_name, '<br/>', wordwrap($item->bank_card, 4, ' ', true), '<br/>', $item->cardholder;?></td>
                                    <td><?php echo $item->mobile_phone, '<br>', $item->pin;?></td>
                                    <td><?php echo $item->is_from == 2 ? '手机端' : '电脑端';?></td>
                                    <td><?php echo '创建时间：', $item->created_at, '<br/> 审核时间：', $item->updated_at;?></td>
                                    <td>
                                        <?php if ($item->status == 2) : ?>
                                            <span class="btn mini green">已付</span>
                                            <?php if ($item->audit_status == 2) : ?> <!-- //提现驳回 -->
                                                <span class="badge label-warning">提现驳回</span>
                                            <?php else : ?>
                                                <?php if ($item->state == 0) : ?>
                                                <a data-toggle="modal" href="#example" data-id="<?php echo $item->withdraw_id;?>" class="badge label-warning virefy">一审审核</a>
                                                <?php elseif ($item->state == 1) : ?>
                                                <a data-toggle="modal" href="#example" data-id="<?php echo $item->withdraw_id;?>" class="badge label-warning virefy">二审审核</a>
                                                <?php elseif ($item->state == 2) : ?>
                                                <span class="btn mini green">审核成功</span>
                                                <?php endif; ?>
                                            <?php endif; ?>
                                        <?php else : ?>
                                            <span class="badge label-info">未付</span>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <a href="<?php echo site_url('withdraw/details/'.$item->withdraw_id); ?>" class="btn mini green">详情</a>
                                    </td>
                                </tr>
                                <?php endforeach;?>
                            </tbody>
                        </table>
                        <div class="row-fluid">
                            <div class="span6">
                                <div class="dataTables_info">
                                    <span>当前第</span><span style="color: red"><?php echo $pg_now?></span>页 
                                    <span>共</span><span style="color: red"><?php echo $all_rows?></span>条数据
                                    <span>每页显示20条 </span>
                                    <?php echo $pg_list ?>
                                </div>
                            </div>
                        </div>
                        <?php else: ?>
                            <div class="alert"><p>未找到数据。<p></div>
                        <?php endif ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="example" class="modal hide fade in" style="display: none; ">
    <form class="form-horizontal" action="<?php echo base_url('withdraw/audit') ?>" method="post">
        <input type="hidden" name="withdraw_id" />
        <div class="modal-header"><a class="close" data-dismiss="modal"></a><h3>提现审核</h3></div>
        <div class="modal-body">
            <div class="control-group">
                <label class="control-label">审核</label>
                <div class="controls">
                    <label class="radio">
                        <div class="radio">
                            <span><input checked="checked"  type="radio" value="1" name="state"></span>
                        </div>
                        审核通过
                    </label>
                    <label class="radio">
                        <div class="radio">
                            <span><input type="radio" value="2" name="state"></span>
                        </div>
                        驳回
                    </label>  
                </div>
            </div>
           <div class="control-group">
                <label class="control-label">备注</label>
                <div class="controls">
                    <textarea rows="3" name="describe" class="large m-wrap"></textarea>
                </div>
            </div>
        </div>
        <div class="modal-footer">
           <button class="btn green" type="submit"><i class="icon-ok"></i> 审核通过</button>
           <button class="btn " data-dismiss="modal" type="button">返回</button>
        </div>
    </form>
</div>

<?php $this->load->view('layout/footer');?>
<script type="text/javascript" >
$(function(){
    $('.virefy').click(function(){
        var id  = $(this).attr('data-id');
        var state = $(this).attr('data-state');
        $('#example input[name=withdraw_id]').val(id);
//      $('#ordereditvirefy').submit();
    });

    $('#example form').submit(function(){
        $('#example form button[type=submit]').attr('disabled', true);
    });
});
</script>